package com.zwj.grpcspringcloudconsumer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class GrpcClientController {

    @Autowired
    private SimpleClientService simpleClientService;

    @Autowired
    private ClientStreamClientService clientStreamClientService;

    @Autowired
    private ServerStreamClientService serverStreamClientService;

    @Autowired
    private DoubleStreamClientService doubleStreamClientService;

    @RequestMapping("/")
    public String printMessage(@RequestParam(defaultValue = "Zhang San") String name) {
        return simpleClientService.sendMessage(name);
    }

    @RequestMapping("/count")
    public String printMessage(@RequestParam(defaultValue = "1") int count) {
        return clientStreamClientService.addToCart(count);
    }

    @RequestMapping("/orders")
    public List<DispOrder> printMessage2(@RequestParam(defaultValue = "will") String name) {
        return serverStreamClientService.listOrders(name);
    }

    @RequestMapping("/deduct")
    public String printMessage3(@RequestParam(defaultValue = "100") int count) {
        return doubleStreamClientService.batchDeduct(count);
    }




}
